import axios from "axios"; 
//  实例：let baseUrl = "https://api.baidu.com/web_v1"
let baseUrl = "https://blogserve.superzhihao.top/api"
const sitemap = {
		hostname: "https://www.superzhihao.top",
		path: '/sitemap.xml',
		cacheTime: 1000 * 60 * 60 * 24, 
		gzip: true, 
		generate: false,
		exclude:[],
		defaults: {
			changefred: "always", 
			lastmod: new Date(),
			priority: 0.8, 
		},
		routes: async () => {
			var routes = [
				{
					url: `/`,
					changefreq: "daily",
					lastmod: new Date(),
					priority: 1,
				},
			]
			// 请求接口  在循环添加生成
			let res = await axios.get(baseUrl+'/article/list', {params: {
					page: 1,
					pagesize: 1000
				}});
			if (res.data.code == 200) {
				let list = res.data.data.list
				let detailList = list.map(item => ({
					url: `/BlogContent/${item.id}`,
					changefreq: "daily",
					priority: 0.9,
				}));
				routes = [
					...routes,
					...detailList,
				]
			}
			return routes
		}
}
export default sitemap;

